package com.yxtec.sc;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.yxtec.sc.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by jerrie on 17-6-28.
 */
@Service
public class MyService {

    @Autowired
    UserServiceClient userServiceClient;

    @HystrixCommand(fallbackMethod = "fallbackNewOne")
    User user() {
        return userServiceClient.user();
    }

    User fallbackNewOne() {
        System.out.println("HystrixCommand fallbackMethod handle...");
        User user = new User();
        user.setId(1);
        user.setName("Bot");
        return user;
    }

}
